package cn.apestar.modules.meibang.meibanguserskillstype.enums;

import cn.apestar.core.base.BaseDictEntity;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Singer_YDW on 2017/5/4.
 */
public enum MasterMJSLevelEnum {

    CY("0", "美甲师-学员"), CJ_1("1", "美甲师-初级1段"), CJ_2("2", "美甲师-初级2段"), ZJ_1("3", "美甲师-中级1段"), ZJ_2(
        "4", "美甲师-中级2段");

    private Object code;

    private String name;

    MasterMJSLevelEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getValue() {

        return code.toString();
    }

    public Long getLongValue() {

        return Long.parseLong((String) code);
    }

    public String getName() {

        return name;
    }

    public static MasterMJSLevelEnum get(String value) {

        if (StringUtils.isBlank(value)) {
            return null;
        }
        MasterMJSLevelEnum[] values = MasterMJSLevelEnum.values();
        for (MasterMJSLevelEnum item : values) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return null;
    }

    public static List getList() {

        List enums = new ArrayList();
        BaseDictEntity baseDictEntity = new BaseDictEntity();
        baseDictEntity.setCode("");
        baseDictEntity.setLabel("无");
        MasterMJSLevelEnum[] values = MasterMJSLevelEnum.values();
        enums.add(baseDictEntity);
        for (MasterMJSLevelEnum item : values) {
            BaseDictEntity dict = new BaseDictEntity();
            dict.setCode(item.getValue());
            dict.setLabel(item.getName());
            enums.add(dict);
        }
        return enums;
    }

    /**
     * 返回该对象的MAP
     *
     * @return MAP集合
     */
    public Map getMap() {

        Map m = new HashMap();
        m.put("type_id", code);
        m.put("type_name", name);
        return m;
    }
}
